package com.neusoft.jxc.exception;

import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neusoft.jxc.bean.Result;

/**
 * 全局Controller层异常处理类
 * 
 * @author chens
 *
 */
@ControllerAdvice
public class GlobalExceptionResolver {
	private static final Logger LOG = Logger.getLogger(GlobalExceptionResolver.class);

	/**
	 * 处理所有不可知异常
	 *
	 * @param e 异常
	 * @return json结果
	 */
	@ExceptionHandler(Exception.class)
	@ResponseBody
	public Result handleException(Exception e) {
		// 打印异常堆栈信息
		LOG.error(e.getMessage(), e);
		return new Result(Boolean.FALSE, "操作有误或系统异常");
	}
}
